<!--会议通知回执 receipt-->
<template>
  <Layout>
    <Spin fix v-if="isSpin">
      <Icon type="ios-loading" size=18 class="demo-spin-icon-load"></Icon>
      <div>正在导出会议回执，请稍后</div>
    </Spin>
    <Form ref="queryForm" :model="dataToQuery" :label-width="120">
      <Row class="query-form">
        <Col span="8">
          <FormItem label="所属单位：">
            <cascaderDom ref="queryOrgCascader" @setOrgInfo="setOrgId" @setOrgname="setOrgName"
                         :orgTree="true"></cascaderDom>
          </FormItem>
        </Col>
        <Col span="8">
          <FormItem label='姓名：'>
            <Input class='' type='text' v-model='dataToQuery.receiptName'></Input>
          </FormItem>
        </Col>

        <Col v-if="!switchFlag" span="8">
          <Button @click="switchQuery(true)" class="ivu-btn-switch" type="text">展开∨</Button>
          <Button @click="reseter" class="ivu-btn-reset">重置</Button>
          <Button type="primary" class="ivu-btn-query" icon="md-search" @click="query">查询</Button>
        </Col>
        <Col v-else span="8">
          <FormItem label="通知公告：">
            <Input class="query-form-el" type="text" v-model="dataToQuery.noticName" @on-focus="querySelect"
                   :readonly="true"></Input>
          </FormItem>
        </Col>
      </Row>

      <Row v-show="switchFlag" class="query-form">
        <Col span="8">
          <FormItem label="参会方式：">
            <Select v-model="dataToQuery.meetingMode">
              <Option value="1" lable="视频参会">视频参会</Option>
              <Option value="2" lable="现场参会">现场参会</Option>
            </Select>
            <!--<Input type="text" v-model="form1datacopy.nation"></Input>-->
          </FormItem>
        </Col>


        <Col span="8" :offset="8">
          <Button @click="switchQuery(false)" class="ivu-btn-switch" type="text">收起∧</Button>
          <Button @click="reseter" class="ivu-btn-reset">重置</Button>
          <Button class="ivu-btn-query" icon="md-search" @click="query">查询</Button>
        </Col>

      </Row>

      <Row class="query-form">
        <Col span="24">
          <Button size="large" class="ivu-btn-add" icon="md-add" @click="add">新增</Button>
          <Button type="primary" class="ivu-btn-add" icon="md-cloud-download" @click="downloadFiles">导出
          </Button>
        </Col>
      </Row>
    </Form>
    <Table ref='table' :height="tableHeight" no-data-text="没有查询到相关数据!" @on-selection-change='getSelectRows'
           :loading='loading'
           border :columns="columns1" :data="dataTable">
    </Table>
    <Row style="margin-right:10px;">
      <Col span="24">
        <Page style="float: right" :total="pagedata.total" :page-size="pagedata.pageSize" @on-change="pageChange"
              @on-page-size-change="pageSizeChange" :page-size-opts="pageSizeArray" show-total show-sizer
              show-elevator/>
      </Col>
    </Row>
    <Modal title="会议回执表新增" :transfer=false :mask-closable="false" v-model="model1" :width=1200>
      <Row>
        <Col span="24">
          <Form ref="dataToView1" :model="form1datacopy" :rules="ruleCustom1" label-position="top">
            <Row type="flex" justify="space-around" class="code-row-bg">
              <Col span="11">
                <FormItem label='通知公告：' prop='noticId'>
                  <Input class='' placeholder="请选择通知公告" type='text' v-model='form1datacopy.noticName'
                         @on-focus="openSelect" :readonly="true"></Input>
                </FormItem>
              </Col>
              <Col span="11">
                <FormItem label='所在单位：' prop='receiptUnitId'>
                  <!-- <Input class='' placeholder="请填写所在单位" type='text' v-model='form1datacopy.receiptUnitName'
                         :readonly="true"></Input> -->
				 <cascaderDom ref="org"
						  class="query-form-el" style="padding-top: 4px;width: 100%"
						  @setOrgInfo="setOrgId1" @setOrgname="setOrgName1"
						  :currentOrgId="form1datacopy.receiptUnitId"
						  :currentOrgName="form1datacopy.receiptUnitName"
						  :orgTree="true"></cascaderDom>
                </FormItem>
              </Col>
            </Row>
            <Row type="flex" justify="space-around" class="code-row-bg">

              <Col span="11">
                <FormItem label='联系人：' prop='createUserName'>
                  <Input class='' placeholder="请填写联系人" type='text' v-model='form1datacopy.createUserName'
                         ></Input>
                </FormItem>
              </Col>
              <Col span="11">
                <FormItem label='联系人电话：' prop='contactNumber'>
                  <Input class='' placeholder="请填写联系电话" type='text' v-model='form1datacopy.contactNumber'></Input>
                </FormItem>
              </Col>
            </Row>
            <Row type="flex" justify="space-around" class="code-row-bg">

              <Col span="11">
                <FormItem label='参会方式：'>
                  <Select v-model="form1datacopy.meetingMode">
                    <Option value="1" lable="视频参会">视频参会</Option>
                    <Option value="2" lable="现场参会">现场参会</Option>
                  </Select>
                </FormItem>
              </Col>
              <Col span="11">

              </Col>
            </Row>
          </Form>
          <Row type="flex" justify="space-around" class="code-row-bg">
            <Col span="23">
              <Button style="margin-top:20px" class="ivu-btn-add" icon="md-add" @click="addPlan()">新增
              </Button>
              <userSelect button-name="批量新增" @setData="setUsers" :singleChoice="false"></userSelect>
            </Col>
          </Row>
          <Row type="flex" justify="space-around" class="code-row-bg">
            <Col span="23">
              <Table class="tableClass" highlight-row stripe border
                     style="margin-top:20px;overflow-y:auto;"
                     :height="350" :columns="planColumn" :data="planDatas">
              </Table>
            </Col>
          </Row>

        </Col>
      </Row>
      <div slot="footer">
        <Button @click="saveAll('dataToView1')" class="ivu-btn-save" :loading="buttonLoading">确定</Button>
        <Button @click="cancel" class="ivu-btn-cancel">取消</Button>
      </div>
    </Modal>
    <Modal title="会议回执表修改" :transfer=false v-model="model3" :width=800 :styles="{height:'559px'}">
      <Row>
        <Col span="24">
          <Form ref="form1datacopy" :show-message="false" :rules="ruleCustom" :model="form1datacopy"
                label-position="top">
            <Row type="flex" justify="space-around" class="code-row-bg">
              <Col span="23">
                <FormItem label='所在单位：' prop='receiptUnitName'>
                  <Input class='' placeholder="请填写所在单位" type='text' v-model='form1datacopy.receiptUnitName'
                         :readonly="true"></Input>
                </FormItem>
              </Col>

            </Row>
            <Row type="flex" justify="space-around" class="code-row-bg">
              <Col span="23">
                <FormItem label='通知公告：' prop='noticId'>
                  <Input class='' placeholder="请填写所在单位" type='text' v-model='form1datacopy.noticName'
                         @on-focus="openSelect" :readonly="true"></Input>
                </FormItem>
              </Col>
            </Row>
            <Row type="flex" justify="space-around" class="code-row-bg">
              <Col span="11">
                <FormItem label='联系人：' prop='userName'>
                  <Input class='' placeholder="请填写联系人" type='text' v-model='form1datacopy.userName'
                         :readonly="true"></Input>
                </FormItem>
              </Col>
              <Col span="11">
                <FormItem label='联系人电话：' prop='contactNumber'>
                  <Input class='' placeholder="请填写联系电话" type='text' v-model='form1datacopy.contactNumber'></Input>
                </FormItem>
              </Col>
            </Row>
            <Row type="flex" justify="space-around" class="code-row-bg">
              <Col span="11">
                <FormItem label='姓名：' prop='receiptName'>
                  <Input class='' placeholder="请填写姓名" type='text' v-model='form1datacopy.receiptName'></Input>
                </FormItem>
              </Col>
              <Col span="11">
                <FormItem label='性别：' prop='receiptSex'>
                  <Select class="query-form-el" v-model="form1datacopy.receiptSex" style="width: 100%;">
                    <Option v-for="item in sexlist" :value="item.value"
                            :key="item.value">{{ item.name }}
                    </Option>
                  </Select>
                </FormItem>
              </Col>
            </Row>
            <Row type="flex" justify="space-around" class="code-row-bg">

              <Col span="11">
                <FormItem label='手机：' prop='receiptPhone'>
                  <Input class='' placeholder="请填写手机" type='text' v-model='form1datacopy.receiptPhone'></Input>
                </FormItem>
              </Col>
              <Col span="11">
                <FormItem label='职务：' prop='receiptPost'>
                  <Input class='' placeholder="请填写职务" type='text' v-model='form1datacopy.receiptPost'></Input>
                </FormItem>
              </Col>
            </Row>
            <Row type="flex" justify="space-around" class="code-row-bg">
              <Col span="11">
                <FormItem label="参会方式：">
                  <Select v-model="form1datacopy.meetingMode">
                    <Option value="1" lable="视频参会">视频参会</Option>
                    <Option value="2" lable="现场参会">现场参会</Option>
                  </Select>
                  <!--<Input type="text" v-model="form1datacopy.nation"></Input>-->
                </FormItem>
              </Col>
              <Col span="11">

              </Col>
            </Row>


            <Row type="flex" justify="space-around" class="code-row-bg">
              <Col span="23">
                <FormItem label='备注：'>
                  <Input class='' placeholder="请填写备注" type='textarea' v-model='form1datacopy.receiptNote'
                         :rows="4"></Input>
                </FormItem>

              </Col>
            </Row>
          </Form>
        </Col>
      </Row>
      <div slot="footer">
        <Button type="primary" class='ivu-btn-save' @click="submit('form1datacopy')" :loading="buttonLoading">确定
        </Button>
        <Button type="primary" class='ivu-btn-cancel' @click="handleCancel">取消</Button>
      </div>
    </Modal>
    <Modal title="会议回执表详情" :transfer=false v-model="model2" :width=700 class="modal-view-detail">
      <Row>
        <Col span="24">
          <Form :model="form1datacopy" :label-width="100">
            <Row type="flex" justify="space-around" class="code-row-bg">
              <Col span="23">
                <FormItem label="所在单位：" prop="receiptOrgName">
                  {{ form1datacopy.receiptUnitName }}
                </FormItem>
              </Col>
            </Row>
            <Row type="flex" justify="space-around" class="code-row-bg">
              <Col span="23">
                <FormItem label="通知公告：" prop="noticName">
                  {{ form1datacopy.noticName }}
                </FormItem>
              </Col>
            </Row>
            <Row type="flex" justify="space-around" class="code-row-bg">
              <Col span="11">
                <FormItem label="联系人：" prop="userName">
                  {{ form1datacopy.userName }}
                </FormItem>
              </Col>
              <Col span="11">
                <FormItem label="联系人电话：" prop="contactNumber">
                  {{ form1datacopy.contactNumber }}
                </FormItem>
              </Col>

            </Row>
            <Row type="flex" justify="space-around" class="code-row-bg">
              <Col span="11">
                <FormItem label="姓名：" prop="receiptName">
                  {{ form1datacopy.receiptName }}
                </FormItem>
              </Col>
              <Col span="11">
                <FormItem label="性别：" prop="receiptSex">
                  {{ renderViewSex(form1datacopy.receiptSex) }}
                </FormItem>
              </Col>

            </Row>
            <Row type="flex" justify="space-around" class="code-row-bg">
              <Col span="11">
                <FormItem label="手机：" prop="receiptPhone">
                  {{ form1datacopy.receiptPhone }}
                </FormItem>
              </Col>
              <Col span="11">
                <FormItem label="职务：" prop="receiptPost">
                  {{ form1datacopy.receiptPost }}
                </FormItem>
              </Col>
            </Row>


            <!--            <Row type="flex" justify="space-around" class="code-row-bg">-->
            <!--              <Col span="23">-->
            <!--                <FormItem label='参会对象：'>-->
            <!--                  <div>{{ form1datacopy.receiptNameNote }}</div>-->
            <!--                </FormItem>-->
            <!--              </Col>-->
            <!--            </Row>-->
            <Row type="flex" justify="space-around" class="code-row-bg">
              <Col span="11">
                <FormItem label='创建人：' prop='userName'>
                  <div>{{ form1datacopy.userName }}</div>
                </FormItem>
              </Col>
              <Col span="11">
                <FormItem label='创建时间：' prop='createDate'>
                  <div>{{ renderViewDate(form1datacopy.createDate) }}</div>
                </FormItem>
              </Col>
            </Row>

            <Row type="flex" justify="space-around" class="code-row-bg">
              <Col span="23">
                <FormItem label="备注：" prop="receiptNote">
                  {{ form1datacopy.receiptNote }}
                </FormItem>
              </Col>
            </Row>
          </Form>
        </Col>
      </Row>
      <div slot="footer">
        <Button class='ivu-btn-save' @click="model2=false">关闭</Button>
      </div>
    </Modal>
    <Modal title="选择通知公告" :transfer=false footer-hide v-model="standardSelectModal" :width=900>
      <noticeSelect type="2" ref="selMission" @selectMission="selectReceipt">
      </noticeSelect>
    </Modal>
    <Modal title="选择通知公告" :transfer=false footer-hide v-model="queryMeetingSelectModal" :width=900>
      <noticeSelect type="2" ref="selQueryMission" :is-select="true" @selectMission="queryMetting">
      </noticeSelect>
    </Modal>
  </Layout>
</template>

<script>
import {Api} from '@/api/index.js'
import {sessionStorage} from "@/common/cacheUtils";
import noticeSelect from '@/views/safe/receipt/NoticeSelect.vue'
import {formatDate} from '@/tools/index'
import userSelect from "@/views/safe/meeting/user-select.vue"

var cascaderDom = () => import('@/components/cascader-dom.vue');
export default {
  components: {
    cascaderDom, noticeSelect, userSelect
  },
  data() {
    return {
      treeListFilter: {},
      orderTreeHead: [
        {
          id: 1,
          loading: false,
          title: '隐患条目',
          expand: false,
          children: []
        }
      ],
      buttonLoading10: false,
      model10: false,
      dataToView: {},
      dataTable: [],
      currentUser: sessionStorage('userId').getObject('userId'),
      model2: false,
      loading: false,
      queryMeetingSelectModal: false,
      switchFlag: false,
      buttonLoading: false,
      model1: false,
      traTypes: [],
      traMethods: [],
      pageSizeArray: [10, 20, 50],
      model3: false,
      isSpin: false,
      pagedata: {
        total: 0,
        pageSize: 10,
        currentPage: 1,
      },
      sexlist: [
        {
          name: '男',
          value: '0',
        },
        {
          name: '女',
          value: '1',
        }
      ],
      isAccommodationList: [
        {
          name: '是',
          value: '1',
        },
        {
          name: '否',
          value: '0',
        }
      ],
      columns1: [
        {title: '序号', width: 80, fixed: 'left', minWidth: 150, align: 'center', render: this.indexColumnsRender},
        {key: 'noticName', title: '通知公告名称', minWidth: 150, align: 'center'},
        {key: 'receiptName', title: '姓名', minWidth: 150, align: 'center'},
        {
          key: 'meetingMode',
          title: '参会方式',
          minWidth: 150,
          align: 'center',
          render: (h, params) => {
            return h('span', params.row.meetingMode == '1' ? '视频参会' : params.row.meetingMode == '2' ? '现场参会' : '')
          }
        },
        {key: 'receiptSex', title: '性别', minWidth: 150, align: 'center', render: this.renderCellSex},
        {key: 'receiptPhone', title: '手机', minWidth: 150, align: 'center'},
        {key: 'receiptPost', title: '职务', minWidth: 150, align: 'center'},
        {key: 'receiptUnitName', title: '所在单位', minWidth: 150, align: 'center'},
        // {key: 'receiptNameNote', title: '参会对象', minWidth: 150, align: 'center', ellipsis: true},
        // {key: 'count', title: '参会人数', minWidth: 150, align: 'center'},
		{key: 'twoLevelName', title: '二级集团', minWidth: 150, align: 'center', ellipsis: true},
        {key: 'receiptNote', title: '备注', minWidth: 150, align: 'center', ellipsis: true},
        {
          title: '操作',
          key: 'action',
          fixed: 'right',
          width: 160,
          align: 'center',
          render: (h, params) => {
            if (this.currentUser.loginId === this.Common.admin || this.currentUser.userId === params.row.createUserId || this.currentUser.userRole.find(obj => obj.roleId == '73b38b37dff64392ba0ee7dd579bf293') != undefined
                    ||sessionStorage('userId').getObject('userId').userBeHandedOver.find(obj => obj == params.row.createUserId) != undefined) {
              return h('div', [
                h('A', {
                  props: {type: 'primary', size: 'small'},
                  style: {fontSize: '14px',},
                  on: {
                    click: () => {
                      this.showData(params, 1);
                    }
                  }
                }, '详情'),
                h('Divider', {props: {type: 'vertical'}}, ''),
                h('A', {
                  props: {type: 'primary', size: 'small'},
                  disabled: true,
                  style: {fontSize: '14px'},
                  on: {
                    click: () => {
                      this.showData(params, 2);
                    }
                  }
                }, '修改'),
                h('Divider', {props: {type: 'vertical'}}, ''),
                h('A', {
                  props: {type: 'primary', size: 'small'},
                  style: {fontSize: '14px', color: 'red'},
                  on: {
                    click: () => {
                      this.deleteData(params);
                    }
                  }
                }, '删除')
              ]);
            } else {
              return h('div', [
                h('A', {
                  props: {type: 'primary', size: 'small'},
                  style: {fontSize: '14px',},
                  on: {
                    click: () => {
                      this.showData(params, 1);
                    }
                  }
                }, '详情'),
                h('Divider', {props: {type: 'vertical'}}, ''),
                h('A', {
                  props: {type: 'primary', size: 'small'},
                  style: {fontSize: '14px', color: '#c5c8ce'}
                }, '修改'),
                h('Divider', {props: {type: 'vertical'}}, ''),
                h('A', {
                  props: {type: 'primary', size: 'small'},
                  style: {fontSize: '14px', color: '#c5c8ce'}
                }, '删除')
              ]);
            }
          }
        }
      ],
      planDatas: [],
      planColumn: [
        {
          type: 'index',
          minWidth: 90,
          align: 'center',
          title: '序号',
        },
        {
          title: '姓名',
          minWidth: 120,
          align: 'center',
          key: 'receiptName',
          render: (h, params) => {
            return h('Input', {
              props: {
                type: 'text',
                value: params.row.receiptName
              },
              on: {
                'on-change': (event) => {
                  params.row.receiptName = event.target.value
                  this.planDatas[params.index] = params.row;

                }
              }
            });
          }
        },
        {
          title: '性别',
          key: 'receiptSex',
          minWidth: 120,
          align: 'center',
          render: (h, params) => {
            return h('Select', {
                  props: {
                    type: 'select',
                    value: params.row.receiptSex
                  },
                  style: {
                    width: '100%',
                    size: 'large'
                  },
                  on: {
                    'on-change': (event) => {
                      params.row.receiptSex = event
                      this.planDatas[params.index] = params.row;
                    }
                  },
                },

                [
                  h('Option', {
                    props: {
                      value: '0'
                    }
                  }, '男'),
                  h('Option', {
                    props: {
                      value: '1'
                    }
                  }, '女'),
                ]
            )
          }
        },
        {
          minWidth: 120,
          title: '参会方式',
          align: 'center',
          slot: 'meetingMode',
          render: (h, params) => {
            return h('Select', {
                  props: {
                    type: 'select',
                    value: params.row.meetingMode
                  },
                  style: {
                    width: '100%',
                    size: 'large'
                  },
                  on: {
                    'on-change': (event) => {
                      params.row.meetingMode = event
                      this.planDatas[params.index] = params.row;
                    }
                  },
                },
                [
                  h('Option', {
                    props: {
                      value: '1'
                    }
                  }, '视频参会'),
                  h('Option', {
                    props: {
                      value: '2'
                    }
                  }, '现场参会'),
                ]
            )
          }
        },
        {
          title: '手机',
          minWidth: 150,
          align: 'center',
          key: 'receiptPhone',
          render: (h, params) => {
            return h('Input', {
              props: {
                type: 'text',
                value: params.row.receiptPhone
              },
              on: {
                'on-change': (event) => {
                  params.row.receiptPhone = event.target.value
                  this.planDatas[params.index] = params.row;
                }
              }
            });
          }
        },
        {
          title: '职务',
          minWidth: 120,
          align: 'center',
          key: 'receiptPost',
          render: (h, params) => {
            return h('Input', {
              props: {
                type: 'text',
                value: params.row.receiptPost
              },
              on: {
                'on-change': (event) => {
                  params.row.receiptPost = event.target.value
                  this.planDatas[params.index] = params.row;

                }
              }
            });
          }
        },
        {
          title: '备注',
          minWidth: 300,
          align: 'center',
          key: 'receiptNote',
          render: (h, params) => {
            return h('Input', {
              props: {
                type: 'text',
                value: params.row.receiptNote
              },
              on: {
                'on-change': (event) => {
                  params.row.receiptNote = event.target.value
                  this.planDatas[params.index] = params.row;

                }
              }
            });
          }
        },
        {
          title: '操作',
          key: 'action',
          align: 'center',
          fixed: 'right',
          minWidth: 150,
          render: (h, params) => {
            return h('div', [
              h('A', {
                props: {
                  type: 'primary',
                  size: 'small'
                },
                style: {
                  color: 'red',
                  fontSize: '14px'
                },
                on: {
                  click: () => {
                    this.$Modal.confirm({
                      title: '数据删除',
                      content: '<p>确定删除该条信息</p>',
                      okText: '确认',
                      onOk: () => {
                        this.deletePlan(params.index);
                      },
                      cancelText: '取消'
                    });

                  }
                }
              }, '删除')
            ]);
          }
        }
      ],
      dataToQuery: {},
      ruleCustom1: {
        contactNumber: [{
          validator: (rule, value, callback) => {
            if (!(/^1[3456789]\d{9}$/.test(this.form1datacopy.contactNumber))) {
              callback(' ')
            } else {
              callback()
            }
          },
          required: true,
          trigger: 'change'
        }],
        noticId: [{
          validator: (rule, value, callback) => {
            if (this.form1datacopy.noticId == null || this.form1datacopy.noticId == undefined || this.form1datacopy.noticId == '') {
              callback(' ')
            } else {
              callback()
            }
          },
          required: true,
          trigger: 'change'
        }],
        createUserName: [{
          validator: (rule, value, callback) => {
            if (this.form1datacopy.createUserName == null || this.form1datacopy.createUserName == undefined || this.form1datacopy.createUserName == '') {
              callback(' ')
            } else {
              callback()
            }
          },
          required: true,
          trigger: 'change'
        }],
        receiptUnitId: [{
          validator: (rule, value, callback) => {
            if (this.form1datacopy.receiptUnitId == null || this.form1datacopy.receiptUnitId == undefined || this.form1datacopy.receiptUnitId == '') {
              callback(' ')
            } else {
              callback()
            }
          },
          required: true,
          trigger: 'change'
        }],
      },
      ruleCustom: {
        userName: [{
          validator: (rule, value, callback) => {
            if (this.form1datacopy.userName == null || this.form1datacopy.userName == undefined || this.form1datacopy.userName == '') {
              callback(' ')
            } else {
              callback()
            }
          },
          required: true,
          trigger: 'change'
        }],
        contactNumber: [{
          validator: (rule, value, callback) => {
            if (!(/^1[3456789]\d{9}$/.test(this.form1datacopy.contactNumber))) {
              callback(' ')
            } else {
              callback()
            }
          },
          required: true,
          trigger: 'change'
        }],
        receiptName: [{required: true, message: '请填写姓名', trigger: 'change',}],
        receiptSex: [{required: true, message: '请填写性别', trigger: 'change',}],
        receiptNation: [{required: true, message: '请填写民族', trigger: 'change',}],
        /*          receiptPhone: [ { required: true, message: '请填写手机', trigger: 'change',}],*/
        receiptPhone: [{
          validator: (rule, value, callback) => {
            if (!(/^1[3456789]\d{9}$/.test(value))) {
              callback(' ')
            } else {
              callback()
            }
          },
          required: true,
          trigger: 'change'
        }],
        receiptPost: [{required: true, message: '请填写职务', trigger: 'change',}],
        receiptEmail: [{required: true, message: '请填写邮箱', trigger: 'change',}],
        receiptUnitName: [{required: true, message: '请填写所在单位', trigger: 'change',}],
        receiptAddress: [{required: true, message: '请填写联系地址', trigger: 'change',}],
        receiptPostcode: [{required: true, message: '请填写邮编', trigger: 'change',}],
        isAccommodation: [{required: true, message: '请填写是否住宿', trigger: 'change',}],
        receiptNote: [{required: true, message: '请填写备注', trigger: 'change',}],


      },
      form1datacopy: {},
      tableHeight: 10,
      traTypeList: [],
      traMethodsList: [],
      // api
      standardSelectModal: false,
      queryUrl: Api.queryMeetingReceipt,
      saveAllUrl: Api.saveAllMeetingReceipt,
      deleteUrl: Api.deleteMeetingReceipt,
      updateUrl: Api.updateMeetingReceipt,
      saveUrl: Api.saveMeetingReceipt,
      downloadUrl: Api.downLoadMeetingReceipt
    }
  },
  mounted() {
    this.dataToQuery = {};
    this.orderTreeHead = [
      {
        id: this.currentUser.companyId,
        type: '1',
        loading: false,
        title: this.currentUser.companyName,
        expand: false,
        children: []
      }
    ]
    this.tableHeight = window.innerHeight - this.$refs.table.$el.offsetTop - 145;
    this.query();
  },
  methods: {
    setUsers(data) {

      data.forEach(item => {
        let user = {
          receiptName: item.userName,
          id: item.userId,
          receiptPhone: item.mobileNumber,
          receiptPost: item.positionName,
          receiptSex: item.sex == 'M' ? '0' : item.sex == 'F' ? '1' : '',

          meetingMode: this.form1datacopy.meetingMode
        }
        this.planDatas.push(user);
      })
    },
    addAll() {
      let _this = this;
      this.orderTreeHead = [
        {
          id: this.currentUser.companyId,
          type: '1',
          loading: true,
          title: this.currentUser.companyName,
          expand: false,
          children: []
        }
      ]
      this.$http.get(Api.meetingReceiptBaseOrgAndUser + "/" + this.currentUser.companyId).then(function (res) {
        if (res.data.status == '200') {
          _this.orderTreeHead =
              [
                {
                  id: this.currentUser.companyId,
                  type: '1',
                  loading: false,
                  title: this.currentUser.companyName,
                  expand: false,
                  children: res.data.data
                }
              ]
        }
      }, function (err) {
        this.$Message.error('请求失败');
      });
      this.model10 = true;
    },
    addSelectplanData() {
      let tree = this.$refs.auditTree.getCheckedNodes();
      this.buttonLoading10 = true;
      if (tree.length != 0) {
        tree.forEach(item => {
          if (item.type == '2') {
            let user = {
              receiptName: item.title,
              id: item.id,
              receiptPhone: item.mobileNum,
            }
            if (!this.treeListFilter[item.id]) {
              this.treeListFilter[item.id] = item.id;
              this.planDatas.push(user);
            }
          }
        })
        this.model10 = false;
      } else {
        this.$Message.warning("请先选择用户")
      }
      this.buttonLoading10 = false;

    },
    addHandleCancel() {
      this.model10 = false;
    },
    showData(data, flag) {
      this.buttonLoading = false;
      if (flag == 1) {
        this.form1datacopy = JSON.parse(JSON.stringify(data.row));

        this.model2 = true;
      } else {
        //修改页面
        this.form1datacopy = JSON.parse(JSON.stringify(data.row));
        this.model3 = true;
      }
    },
    indexColumnsRender(h, params) {
      return h('span', params.index + (this.pagedata.currentPage - 1) * this.pagedata.pageSize + 1);
    },
    deleteDateById(id) {
      this.$Modal.confirm({
        title: '提示',
        content: '<p>确认删除此行数据？</p>',
        onOk: () => {
          let url = this.deleteUrl;
          this.$http.delete(url + '/' + id, {params: {}}).then((res) => {
            if (res.data.status === 200) {
              this.$Message.success('删除成功');
              this.query1()
            } else if (res.data.status === 201) {
              this.$Message.error(res.data.msg);
            }
          }).catch(e => {
            this.$Message.error('删除失败' + e);
          })
        },
        onCancel: () => {
        }
      });
    },

    deletePlan(index) {
      let data = this.planDatas[index];
      delete this.treeListFilter[data.id];
      this.planDatas.splice(index, 1);
    },
    renderCellSex(h, params) {
      let key = params.column.key;
      if (!params.row[key]) return "";
      return h('span', params.row[key] === '0' ? '男' : '女')
    },
    queryMetting(row) {
      this.queryMeetingSelectModal = false;
      this.dataToQuery.noticId = row.proposalId;
      this.dataToQuery.noticName = row.title;
    },
    renderViewDate(date) {
      if (!date) return "";
      return formatDate(new Date(date), "yyyy-MM-dd");
    },
    handleCancel() {
      this.form1datacopy = {};
      this.model1 = false;
      this.model3 = false;
      this.planDatas = [];
    },
    query1() {
      this.loading = true
      let data = {
        startPage: this.pagedata.currentPage,
        size: this.pagedata.pageSize,
        orgId: sessionStorage('userId').getObject('userId').companyId,
      };
      data = Object.assign(data, JSON.parse(JSON.stringify(this.dataToQuery)));
      this.$http.get(this.queryUrl, {params: data}).then((res) => {
        if (res.data.status === 201) {
          this.$Message.error(res.data.msg);
        }
        this.dataTable = res.data.data.data;
        this.pagedata.total = res.data.data.totalSize;
        this.loading = false
      }).catch(e => {
        this.$Message.error("数据获取失败")
        this.loading = false
      })
    },
    add() {
      this.form1datacopy = {};
      this.form1datacopy.companyId = this.currentUser.companyId;
      this.form1datacopy.companyName = this.currentUser.companyName;
      this.form1datacopy.belongOrgId = this.currentUser.twoLevelOrgId;
      this.form1datacopy.belongOrgName = this.currentUser.twoLevelOrgName;
      this.form1datacopy.registrant = this.currentUser.userName;
      this.form1datacopy.contactNumber = this.currentUser.mobileNumber;
      this.form1datacopy.registTime = new Date();
      this.form1datacopy.receiptUnitId = this.currentUser.companyId;
      this.form1datacopy.receiptUnitName = this.currentUser.companyName;
      this.planDatas = [];

      let _this = this;
      this.treeListFilter = {};
      this.model1 = true;

    },
    cancel() {
      this.form1datacopy = {};
      this.model1 = false;
    },
    renderCellAccommodation(h, params) {
      let key = params.column.key;
      if (!params.row[key]) return "";
      return h('span', params.row[key] === '1' ? '是' : '否')
    },

    renderViewSex(data) {
      if (!data) return "";
      return data === '0' ? '男' : '女'
    },
    renderViewAccommodation(data) {
      if (!data) return "";
      return data === '1' ? '是' : '否';
    },
    setOrgId1(data) {
      this.form1datacopy.receiptUnitId = data[data.length - 1];
    },
    setOrgName1(data) {
       this.form1datacopy.receiptUnitName = data;
    },
    setOrgId(data) {
      this.dataToQuery.receiptUnitId = data[data.length - 1];
    },
    setOrgName(data) {
      this.dataToQuery.orgName = data;
    },
    selectTraType(item) {
      this.form1datacopy.traTypeName = item.label;
      this.form1datacopy.traTypeId = item.value;
    },
    selectTraMethods(item) {
      this.form1datacopy.traMethodsName = item.label;
      this.form1datacopy.traMethodsId = item.value;
    },
    deleteData(params) {
      this.deleteDateById(params.row.id);
    },
    switchQuery(flag) {
      this.switchFlag = flag;
      if (!this.switchFlag) {
        this.tableHeight = this.tableHeight + 44;
      } else {
        this.tableHeight = this.tableHeight - 44;
      }
    },
    query() {
      this.dataToQuery.traTypeId = "";
      this.dataToQuery.traMethodsId = "";
      this.pagedata.currentPage = 1;
      this.pagedata.pageSize = 10;
      this.traTypes.forEach(item => {

        this.dataToQuery.traTypeId += item + ","
      });
      this.traMethods.forEach(item => {

        this.dataToQuery.traMethodsId += item + ","
      });

      this.query1()
    },
    selectSafeLevel(row) {
      this.form1datacopy.safeLevelId = row.value;
      this.form1datacopy.safeLevel = row.label;
    },
    pageChange(pageNum) {
      this.pagedata.currentPage = pageNum;
      this.query1();
    },
    pageSizeChange(pageSize) {
      this.pagedata.pageSize = pageSize;
      this.query1();
    },
    selectstdRank(stdRank) {
      this.form1datacopy.safeRankId = stdRank.value;
      this.form1datacopy.safeRank = stdRank.label;
    },
    selectstdIndustry(row) {
      this.form1datacopy.industryId = row.value;
      this.form1datacopy.industry = row.label;
    },
    saveAll(name) {
      this.$refs[name].validate((valid) => {
        if (valid) {
          this.buttonLoading = true;
          let userId = sessionStorage('userId').getObject('userId').userId;
          let orgId = sessionStorage('userId').getObject('userId').orgInfo.orgId;
          if (this.planDatas.length != 0) {

            this.planDatas.forEach(item => {
              item.id = this.get_uuid();
              item.filesId = this.form1datacopy.filesId;
              item.noticId = this.form1datacopy.noticId;
              item.contactNumber = this.form1datacopy.contactNumber;
              item.noticName = this.form1datacopy.noticName;
              item.receiptUnitId = this.form1datacopy.receiptUnitId;
              item.receiptUnitName = this.form1datacopy.receiptUnitName;
              item.createUserId = userId;
              item.createOrgId = orgId;
            });
            this.$http.post(this.saveAllUrl, this.planDatas).then((res) => {
              this.$Message.success("保存成功");
              this.model1 = false;
              this.query();
              this.buttonLoading = false;
            }).catch(e => {
              this.model1 = false;
              this.query();
              this.$Message.error("数据获取失败")
            })
          } else {
            this.buttonLoading = false;
            this.$Message.error("请新增数据")
          }
        } else {
          this.$Message.error('请填报完整!');
        }
      })
    },
    submit(name) {
      this.$refs[name].validate((valid) => {
        if (valid) {
          this.buttonLoading = true;
          let userId = sessionStorage('userId').getObject('userId').userId;
          let orgId = sessionStorage('userId').getObject('userId').orgInfo.orgId;
          this.form1datacopy.updateUserId = userId;
          this.form1datacopy.updateOrgId = orgId;
          this.$http.put(this.updateUrl, this.form1datacopy).then((res) => {
            this.$Message.success("保存成功")
            this.model3 = false;
            this.query1();
            this.buttonLoading = false;
          }).catch(e => {
            this.model3 = false;
            this.query1();
            this.$Message.error("数据获取失败")
          })

        } else {
          this.$Message.error('请填报完整!');
        }
      })
    },
    createEmptyDataToAdd() {
      return {
        filesId: this.get_uuid(),
        receiptUnitId: sessionStorage('userId').getObject('userId').companyId,
        receiptUnitName: sessionStorage('userId').getObject('userId').companyName,
        createUserName: sessionStorage('userId').getObject('userId').userName,

      }
    },
    get_uuid() {
      let s = [];
      let hexDigits = "0123456789abcdef";
      for (let i = 0; i < 36; i++) {
        s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1);
      }
      s[14] = "4";
      s[19] = hexDigits.substr((s[19] & 0x3) | 0x8, 1);
      s[8] = s[13] = s[18] = s[23] = "-";

      let uuid = s.join("");
      let reg = new RegExp("-", "g");
      let a = uuid.replace(reg, "");
      console.log(a);
      return a;
    },
    reseter() {
      this.traTypes = [];
      this.traMethods = [];
      this.dataToQuery = {};
      this.$refs.queryOrgCascader.resetCurrentOrg();
      this.query1()
    },
    selectReceipt(row) {
      this.standardSelectModal = false;
      this.form1datacopy.noticId = row.proposalId;
      this.form1datacopy.noticName = row.title;
    },
    openSelect() {
      this.standardSelectModal = true

    },
    querySelect() {
      this.queryMeetingSelectModal = true

    },
    downloadFiles() {
      this.isSpin = true;
      let orgId = sessionStorage('userId').getObject('userId').companyId;
      let data = {
        orgId: orgId
      };
      data = Object.assign(data, JSON.parse(JSON.stringify(this.dataToQuery)));
      this.$http.get(this.downloadUrl, {
        params: data,
        responseType: 'blob'      //告诉服务器我们需要的响应格式
      }).then((res) => {
        const aLink = document.createElement("a");
        let blob = new Blob([res.data], {
          type: res.bodyBlob.type      //将会被放入到blob中的数组内容的MIME类型
        });
        aLink.href = URL.createObjectURL(blob)
        aLink.download = "会议回执表(" + formatDate(new Date(), "yyyy-MM-dd") + ").xlsx" //标题
        aLink.click()
        document.body.appendChild(aLink)
        this.isSpin = false;
      })
    },
    addPlan() {
      let item = {}
      this.planDatas.push(item);
    },
    getSelectRows(rows) {
      this.deleteRows = rows;
    },
  },
  watch: {
    "model1": function (qw, er) {
      if (qw && this.model1) {
        setTimeout(() => {
          this.$refs.org.setCurrentOrg();

        }, 100)
      } else {
        this.$refs.org.resetCurrentOrg();

      }
    },
 }

}
</script>

<style lang='css' scoped>
.tableClass {
}

.tableClass >>> .ivu-table td {
  vertical-align: middle;
}

.tableClass >>> .ivu-table th {
  vertical-align: middle;
}

.tableClass >>> .ivu-input-suffix i {
  font-size: 16px;
  line-height: 50px;
  color: #808695;
}

/*.tableClass >>> .ivu-select-selection {
    height: 100%;
}
.tableClass >>> .ivu-select-selected-value {
    display: block;
    text-align: center;
}*/

.tableClass >>> .ivu-input {
  border-radius: 0px;
  vertical-align: middle;
  height: 100%;
}

.tableClass >>> textarea.ivu-input {
  height: 100%;
  vertical-align: middle;
}

.tableClass >>> ivu-date-picker {
  height: 100%;
  vertical-align: middle;
}

.tableClass >>> .ivu-table-cell {
  padding-left: 0px;
  padding-right: 0px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: normal;
  word-break: break-all;
  box-sizing: border-box;
  height: 100%;
  /*flex 布局*/
  display: flex;
  /*实现垂直居中*/
  align-items: center;
  /*实现水平居中*/
  justify-content: center;
  text-align: justify;
}

.tableClass >>> .ivu-date-picker {
  height: 100%;
}

.tableClass >>> .ivu-date-picker {
  height: 100%;
}

.tableClass >>> .ivu-input-wrapper {
  height: 100%;
}

.tableClass >>> .ivu-date-picker-rel {
  height: 100%;
}

.tableClass >>> .ivu-input-icon {
  line-height: 50px;
}

.demo-spin-icon-load {
  animation: ani-demo-spin 1s linear infinite;
}

@keyframes ani-demo-spin {
  from {
    transform: rotate(0deg);
  }
  50% {
    transform: rotate(180deg);
  }
  to {
    transform: rotate(360deg);
  }
}
</style>
